package com.ihrm.common.utils;

import java.math.BigDecimal;

/**
 * 常量
 *
 * @author Mark sunlightcs@gmail.com
 */
public class Constant {
    /** 超级管理员ID */
    public static final String SUPER_ADMIN = "1343916938455912450";
    /** 数据权限过滤 */
    public static final String SQL_FILTER = "sql_filter";
    /**
     * 当前页码
     */
    public static final String PAGE = "page";
    /**
     * 每页显示记录数
     */
    public static final String LIMIT = "limit";
    /**
     * 排序字段
     */
    public static final String ORDER_FIELD = "sidx";
    /**
     * 排序方式
     */
    public static final String ORDER = "order";
    /**
     *  升序
     */
    public static final String ASC = "asc";

     /**
     * 菜单类型
     */
    public enum MenuType {
        /**
         * 目录
         */
        CATALOG(0),
        /**
         * 菜单
         */
        MENU(1),
        /**
         * 按钮
         */
        BUTTON(2);

        private int value;

        MenuType(int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }
    }

    /**
     * 定时任务状态
     */
    public enum ScheduleStatus {
        /**
         * 正常
         */
        NORMAL(0),
        /**
         * 暂停
         */
        PAUSE(1);

        private int value;

        ScheduleStatus(int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }
    }

    /**
     * 云服务商
     */
    public enum CloudService {
        /**
         * 七牛云
         */
        QINIU(1),
        /**
         * 阿里云
         */
        ALIYUN(2),
        /**
         * 腾讯云
         */
        QCLOUD(3);

        private int value;


        public enum State {

            /**
             * 启用
             */
            ENABLE("state", 1, "启用"),

            /**
             * 禁用
             */
            DISABLE("state", 2, "禁用"),

            /**
             * 允许
             */
            PERMIT("permit", 1, "允许"),

            /**
             * 不允许
             */
            NOT_PERMIT("permit", 2, "不允许"),

            /**
             * 审核中
             */
            AUDITING("audit", 1, "审核中"),

            /**
             * 不允许
             */
            AGREE("audit", 2, "同意"),

            /**
             * 不允许
             */
            REFUSE("audit", 3, "拒绝"),

            /**
             * 不允许
             */
            WITHDRAW_AUDITING("withdraw", 1, "审核中"),

            /**
             * 已完成
             */
            FINISHED("withdraw", 2, "已完成"),

            /**
             * 已驳回
             */
            REJECTED("withdraw", 3, "已驳回"),
            /**
             * 已完成
             */
            MEMBER_FINISHED("memberWithdraw", 1, "已完成"),

            /**
             * 已驳回
             */
            MEMBER_REJECTED("memberWithdraw", 2, "已驳回"),
            ;
            private String type;
            private int code;
            private String name;

            State(String type, int code, String name) {
                this.type = type;
                this.code = code;
                this.name = name;
            }

            public String getType() {
                return type;
            }

            public void setType(String type) {
                this.type = type;
            }

            public int getCode() {
                return this.code;
            }

            public void setCode(int code) {
                this.code = code;
            }

            public String getName() {
                return this.name;
            }

            public void setName(String name) {
                this.name = name;
            }

            public static String getNameByTypeAndCode(String type, int code) {
                State[] states = values();
                for (State state : states) {
                    if (state.type.equals(type) && state.code == code) {
                        return state.name;
                    }
                }
                return null;
            }
        }


        CloudService(int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }
    }

    public enum State {

        /**
         * 启用
         */
        ENABLE("state", 1, "启用"),

        /**
         * 禁用
         */
        DISABLE("state", 2, "禁用"),

        /**
         * 允许
         */
        PERMIT("permit", 1, "允许"),

        /**
         * 不允许
         */
        NOT_PERMIT("permit", 2, "不允许"),

        /**
         * 审核中
         */
        AUDITING("audit", 1, "审核中"),

        /**
         * 不允许
         */
        AGREE("audit", 2, "同意"),

        /**
         * 不允许
         */
        REFUSE("audit", 3, "拒绝"),

        /**
         * 不允许
         */
        WITHDRAW_AUDITING("withdraw", 1, "审核中"),

        /**
         * 已完成
         */
        FINISHED("withdraw", 2, "已完成"),

        /**
         * 已驳回
         */
        REJECTED("withdraw", 3, "已驳回"),
        ;

        private String type;
        private int code;
        private String name;


        State(String type, int code, String name) {
            this.type = type;
            this.code = code;
            this.name = name;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public int getCode() {
            return this.code;
        }

        public void setCode(int code) {
            this.code = code;
        }

        public String getName() {
            return this.name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public static String getNameByTypeAndCode(String type, int code) {
            State[] states = values();
            for (State state : states) {
                if (state.type.equals(type) && state.code == code) {
                    return state.name;
                }
            }
            return null;
        }
    }
}
